import { Button, Card, Icon, message, Spin, Table, Tooltip } from "antd";
import { connect } from "dva";
import { routerRedux } from "dva/router";
import moment from "moment";
import PropTypes from "prop-types";
import React, { PureComponent } from "react";
import enums from "../creditCar/enums";
import PateoAuthButtons from "@/common/PateoAuthButtons/PateoAuthButtons";
import * as G from "@/utils/common";
import SearchAdtional from "../creditCar/component/searchAdtional/index";
import MsgRulerModal from "../warningCar/msgRulerModal";
import CustomerSearchForm from "./customerSearchForm";
import ExportTaskModal from "./exportTaskModal";
import FieldModal from "./fieldModal";
import styles from '@/common/form.less';
import SendMsgModal from "./sendMsgModal";
import RiskStatusModal from "../creditCar/riskStatusModal";
import { Form } from '@ant-design/compatible';
import { getDicByKey, getDictOptionsByCode } from '@/support/common';
import { SettingOutlined } from '@ant-design/icons';
import RiskLogModal from "../creditCar/riskLogModal";
import DealerRiskManageModal from "../creditCar/dealRiskManageModal";

// 下划线转驼峰
function toCamel(str) {
  return str.replace(/([^_])(?:_+([^_]))/g, function ($0, $1, $2) {
    return $1 + $2.toUpperCase();
  });
}
@connect((state) => ({
  overdueCar: state.overdueCar,
  menu: state.menu,
  currentUser: state.user.currentUser,
}))
@Form.create()
export default class OverdueCar extends PureComponent {
  static contextTypes = {
    authButton: PropTypes.array,
    dicData: PropTypes.any,
  };

  state = {
    formValues: {},
    pageObj: {
      curPage: 1,
      pageSize: 10,
    },
    total: 0,
    sendMsgModalVisible: false,
    exportTaskVisible: false,
    selectedRecord: {},
    userList: [],
    tboxRouseloading: false,
    tboxRouseCount: 35,
    columnsOptions: [], // 可以显示的字段
    fieldList: [], // 列表可显示动态字段
    fieldMore: [], // 更多筛选可以使用的字段
    fieldAdd: [], // 新增可用字段
    riskEventList: [],
    fieldColumns: [],
    orgList: [],
    seriesList: [],

    tableColumns: [], //动态列表clonmn
    fieldList: [],
    visible: false,
    checked: [],
    currentSearchMode: "1",

    ruleList: [],
    msgRuleModalVisible: false,
    ruleListSelectedRecord: {},
    ruleListType: 1,

    riskStatusModalVisible: false,
    riskvin: undefined,
    creditType: undefined,
    creditTypeOptions: [],
    tableData: [],
    tableLoading: false,
    riskLogModalVisible:false,//风控日志
    dealRiskManageModalVisible:false,//经销商风险管理
  };

  handlemsgRemove = (record) => {
    const { dispatch } = this.props;
    let params = {
      businessCode: "over-due-log",
      vin: record.vin,
    };

    dispatch({
      type: "overdueCar/postDataWithRes",
      payload: {
        url: "/mscreditbusiness/vehicle/ivi/warn/remove",
        ...params,
      },
      callback: (response) => {
        if (response.statusCode === "0") {
          message.success("修改成功");
          this.handleTableNewData();
        } else {
          // message.error(response.statusMessage);
        }
      },
    });
  };
  handleWarnMsg = (record) => {
    let params = {
      businessCode: "over-due-log",
      vin: record.vin,
      iviNoticeId: "",
    };
    this.props.dispatch({
      type: "overdueCar/postDataWithRes",
      payload: {
        url: "/mscreditbusiness/vehicle/ivi/warn",
        ...params,
      },
      callback: (response) => {
        if (response.statusCode === "0") {
          message.success("发送成功");
          this.handleTableNewData();
        } else {
          message.error(response.statusMessage);
        }
      },
    });
  };
  // 查询当前商户有效车机告警规则列表
  handlemsgRulerList = (record, type) => {
    // 0-正常行驶，1-锁车，2-跛行
    // let showTypes = [2, 3];
    // if (record.riskStatus == "正常行驶" ) {
    //   showTypes = [1, 2, 3];
    // }
    let params = {};
    if (type == 1) {
      // 正常行驶
      if (record.riskStatus == 0) {
        params = {
          showTypes: [1, 2, 3],
          useType: 3,
        };
      } else if (record.riskStatus == 1) {
        params = {
          showTypes: [1, 2, 3],
          useType: 2,
        };
      } else if (record.riskStatus == 2) {
        params = {
          showTypes: [1, 2, 3],
          useType: 1,
        };
      } else {
        params = {
          showTypes: [1, 2, 3],
          useType: 3,
        };
      }
    } else if (type == 2) {
      //锁车
      params = {
        showTypes: [1, 2, 3],
        useType: 2,
      };
    } else if (type == 3) {
      params = {
        showTypes: [1, 2, 3],
        useType: 1,
      };
    }
    this.props.dispatch({
      type: "overdueCar/postObjWithRes",
      payload: {
        url: "/mscreditbusiness/iviNotice/list",
        ...params,
      },
      // type: "thirdOrgCreditVehicleRiskImpleRule/noticeList",
      // payload: params,
      callback: (response) => {
        if (response && response.statusCode == "0") {
          this.setState({
            ruleList: response.data,
            msgRuleModalVisible: true,
            ruleListSelectedRecord: record,
            ruleListType: type,
          });
        } else {
          // message.error(response.statusMessage);
        }
      },
    });
  };

  componentDidMount() {
    const { dispatch } = this.props;
    this.getDic();
    this.getFieldList();

    this.handleGetOrgList();
    this.handleGetriskEventList();
    this.handleGetFieldList();
    this.handleGetSeriesByBrandCode();
    // //  组织机构列表
    // dispatch({
    //   type: "overdueCar/queryOrgList",
    //   payload: {},
    // });
    // 已生效的异常事件列表
    // dispatch({
    //   type: "overdueCar/abnormalList",
    //   payload: {},
    // });
    // if (this.props.location && this.props.location.state) {
    //   const { pageObj, formValues } = this.props.location.state;
    //   setTimeout(() => {
    //     this.unit.setFieldsValue({
    //       ...formValues,
    //     });
    //   }, 500);
    //   this.setState(
    //     {
    //       formValues,
    //       pageObj,
    //     },
    //     () => {
    //       this.handleTableNewData();
    //     }
    //   );
    // } else {
      this.handleTableNewData();
    // }
  }
  getDic = () =>{
    const {menu: { dicData }} = this.props;
    const typeOption = getDictOptionsByCode(dicData, 'creditType');
    this.setState({
      creditTypeOptions: typeOption.map(e => ({
            label: e.label,
            value: e.value,
          })),
   })
  }
  handleGetSeriesByBrandCode = () => {
    this.props.dispatch({
      type: "overdueCar/getDataWithRes",
      payload: { url: '/msdevice/base/vehicle/series/list' },
      callback: (response) => {
        this.setState({
          seriesList: response.data.map(e => ({
            label: e.seriesName,
            value: e.seriesCode,
          })),
        });
      },
    });
  };
  handleGetriskEventList = () => {
    this.props.dispatch({
      type: "overdueCar/postObjWithRes",
      payload: {
        url: "/mscreditbusiness/event/page",
        ...{
          curPage: 1,
          pageSize: 1000,
          enable: enums.riskEventEnable.effective.value,
        },
      },
      callback: (response) => {
        if (response && response.statusCode == "0") {
          this.setState({
            riskEventList: response.data.rows.map((i) => ({
              value: i.uuid,
              label: i.riskEventContent,
            })),
          });
        } else {
          message.error(response.statusMessage);
        }
      },
    });
  };
  loop = (arr) => {
    let tree= JSON.parse(JSON.stringify(arr))
      let newData = []
    const expanded = datas => {
      if (datas&& datas.length > 0){
        datas.forEach(e => {
          newData.push({sid: e.sid, name: e.orgName});
          expanded(e.children);
        })
      }
    };
    expanded(tree);
    return newData;
  }
  handleGetOrgList = () => {
    this.props.dispatch({
      type: "overdueCar/getDataWithRes",
      payload: {
        url: "/org/tree",
      },
      callback: (response) => {
        if (response && response.statusCode == "0") {
          if (response.data && response.data.length > 0) {
           const newData =  this.loop(response.data)
            this.setState({
              orgList: newData,
            });
          }
        } else {
          message.error(response.statusMessage);
        }
      },
    });
  };
  componentWillUnmount() {
    clearInterval(this.timer2);
    clearInterval(this.timer);
  }

  addPreinstall = (columns) => {
    return columns.map((i) => {
      const sameTitle = columns.some(
        (j) => j.name === i.name && i.fieldId !== j.fieldId
      );
      if (sameTitle && i.fieldId) {
        i.name = `${i.name}(预设)`;
      }
      return i;
    });
  };
  getFieldList = () => {
    // 获取列表字段
    this.props.dispatch({
      type: "overdueCar/postDataWithRes",
      payload: {
        url: "/mscreditbusiness/credit/merchant/field/scenelist?menu=overdue&scene=list",
      },
      callback: (response) => {
        if (response && response.statusCode == "0") {
          if (response.data && response.data.length > 0) {
            let arr = [];
            this.addPreinstall(response.data).map((item) => {
              if (item.type === 4) {
                arr.push({
                  title: item.name,
                  dataIndex: toCamel(item.column),
                  key: toCamel(item.column),
                  render: (text) => {
                    if (typeof text == "number") {
                      return text ? moment(text).format("YYYY-MM-DD") : "";
                    } else {
                      return text
                        ? moment(text, "YYYY-MM-DD").format("YYYY-MM-DD")
                        : "";
                    }
                  },
                });
              } else if (item.type === 5) {
                arr.push({
                  title: item.name,
                  dataIndex: toCamel(item.column),
                  key: toCamel(item.column),
                  render: (text) => {
                    if (typeof text == "number") {
                      return text ? moment(text).format("HH:mm:ss") : "";
                    } else {
                      return text
                        ? moment(text, "HH:mm:ss").format("HH:mm:ss")
                        : "";
                    }
                  },
                });
              } else if (item.type === 6) {
                arr.push({
                  title: item.name,
                  dataIndex: toCamel(item.column),
                  key: toCamel(item.column),
                  render: (text) => {
                    if (typeof text == "number") {
                      return text
                        ? moment(text).format("YYYY-MM-DD HH:mm:ss")
                        : "";
                    } else {
                      return text
                        ? moment(text, "YYYY-MM-DD HH:mm:ss").format(
                            "YYYY-MM-DD HH:mm:ss"
                          )
                        : "";
                    }
                  },
                });
              } else if (item.name === "是否支持跛行") {
                arr.push({
                  title: item.name,
                  dataIndex: toCamel(item.column),
                  key: toCamel(item.column),
                  render: (text) => {
                    return text == 1 ? "是" : "否";
                  },
                });
              } else if (item.name === "车辆预警状态") {
                arr.push({
                  title: item.name,
                  dataIndex: toCamel(item.column),
                  key: toCamel(item.column),
                  render: (text) => {
                    if (text == "0") {
                      return "未预警";
                    } else if (text == "1") {
                      return "预警";
                    } else {
                      return text;
                    }
                  },
                });
              } else if (item.name === "还款状态") {
                arr.push({
                  title: item.name,
                  dataIndex: toCamel(item.column),
                  key: toCamel(item.column),
                  render: (text) => {
                    if (text == "0") {
                      return "还款中";
                    } else if (text == "1") {
                      return "已逾期";
                    } else if (text == "2") {
                      return "已结清";
                    } else if (text == "3") {
                      return "融资已到期";
                    } else {
                      return "未知";
                    }
                  },
                });
              } else if (item.name === "车辆风控状态") {
                arr.push({
                  title: item.name,
                  dataIndex: toCamel(item.column),
                  key: toCamel(item.column),
                  render: (text, record) => {
                    if (text == 0) {
                      return "正常行驶"; 
                    } else if (text == 1) {
                      return "锁车"; 
                    } else if (text == 2) {
                      return "跛行"; 
                    } else {
                      return text;
                    }
                  },
                });
              } else if (item.name === "车机告警类型") {
                arr.push({
                  title: item.name,
                  dataIndex: toCamel(item.column),
                  key: toCamel(item.column),
                  render: (text) => {
                    if (text == 0) {
                      return "暂不支持";
                    } else if (text == 1) {
                      return "不可配置";
                    } else if (text == 2) {
                      return "可配置";
                    } else {
                      return text;
                    }
                  },
                });
              } else if (item.name === "车机告警状态") {
                arr.push({
                  title: item.name,
                  dataIndex: toCamel(item.column),
                  key: toCamel(item.column),
                  render: (text) => {
                    if (text == 0) {
                      return "正常";
                    } else if (text == 1) {
                      return "车机告警";
                    } else {
                      return text;
                    }
                  },
                });
              } else if (item.name === "实车当前状态") {
                arr.push({
                  title: item.name,
                  dataIndex: toCamel(item.column),
                  key: toCamel(item.column),
                  render: (text) => {
                    if (text == 0) {
                      return "正常";
                    } else if (text == 1) {
                      return "锁车";
                    } else if (text == 2) {
                      return "跛行";
                    } else if (text == 3) {
                      return "待车辆反馈";
                    } else {
                      return "待车辆反馈";
                    }
                  },
                });
              } else if (item.name === "授信类型") {
                arr.push({
                  title: item.name,
                  dataIndex: toCamel(item.column),
                  key: toCamel(item.column),
                  render: text => {
                    if (text == null) {
                      return '';
                    }
                    return getDicByKey(this.context.dicData, `creditType`, text.toString());
                  },
                });
              }else if (item.name === "经销商名称") {
                arr.push({
                  title: item.name,
                  dataIndex: toCamel(item.column),
                  key: toCamel(item.column),
                  render: (text, record) => {
                    if (text) {
                      return <a onClick={() => this.dealerRiskManage(record)}>{text}</a>;
                    } else {
                      return '';
                    }
                  },
                });
              }else {
                arr.push({
                  title: item.name,
                  dataIndex: toCamel(item.column),
                  key: toCamel(item.column),
                });
              }
            });
            arr = arr.map((i) => {
              i.columnShow = true;
              return i;
            });
            this.setState({
              tableColumns: this.fieldModal.getTableColumns(arr),
            });
          }
        } else {
          message.error(response.statusMessage);
        }
      },
    });
  };
  openFieldModal = () => {
    this.fieldModal.open(this.state.tableColumns);
  };
  handleGetFieldList = () => {
    this.props.dispatch({
      // 更多筛选数据
      type: "overdueCar/postDataWithRes",
      payload: {
        url: "/mscreditbusiness/credit/merchant/field/scenelist?menu=overdue&scene=more",
      },
      callback: (response) => {
        if (response && response.statusCode == "0") {
          if (response.data && response.data.length > 0) {
            this.setState({
              fieldMore: this.addPreinstall(response.data),
            });
          }
        } else {
          message.error(response.statusMessage);
        }
      },
    });
  };

  handleTableNewData = () => {
    // handleTableNewDataFN
    // handleTableNewDatatest
    let params = [];
    const {
      pageObj: { curPage, pageSize },
      fieldColumns,
      currentSearchMode,
    } = this.state;
    if (currentSearchMode == "1") {
      params = this.exChangeDefaultData().filter(
        (i) =>
          !(
            i.startVal === undefined ||
            i.startVal === null ||
            i.startVal === ""
          )
      );
    } else {
      params = fieldColumns;
    }
    this.props.dispatch({
      type: "overdueCar/postObjWithRes",
      payload: {
        url: "/mscreditbusiness/vehicle/overdue/page",
        curPage,
        pageSize,
        conditions: params,
        // businessCode: "overdue",
      },
      callback: (response) => {
        if (response && response.statusCode == "0" && response.data) {
          if (
            response.data.rows.length === 0 &&
            response.data.pagination.current > 1
          ) {
            this.setState(
              {
                pageObj: {
                  curPage: 1,
                  pageSize: 10,
                },
              },
              () => {
                this.handleTableNewData();
              }
            );
          } else {
            this.setState({
              tableData: response.data.rows,
              total: response.data.pagination.total,
            });
          }
        } else {
          if (response.statusCode !== "0") {
            // message.error(response.statusMessage);
          }
        }
        this.setState({
          tableLoading: false,
        });
      },
    });
  };
  specialDataGenrator = () => {
    // 生成特殊字段
    return [
      {
        // 所属公司
        columnName: "vin",
        columnType: 1,
        // filter: 9,
        startVal: undefined,
        endVal: undefined,
        filterType: 1,
      },
      {
        // 所属公司
        columnName: "company_name",
        columnType: 2,
        extra: {
          selectType: 0,
          optionList: this.state.orgList.map((i) => ({
            label: i.name,
            value: i.sid,
          })),
        },
        // filter: 9,
        startVal: undefined,
        endVal: undefined,
        filterType: 1,
      },
      {
        // 实车当前状态
        columnName: "vhl_current_status",
        columnType: 2,
        extra: {
          selectType: 0,
          optionList: [
            {
              value: 0,
              label: "正常",
            },
            {
              value: 1,
              label: "锁车",
            },
            {
              value: 2,
              label: "跛行",
            },
            {
              value: 3,
              label: "待车辆反馈",
            },
          ],
        },
        // filter: 9,
        startVal: undefined,
        endVal: undefined,
        filterType: 1,
      },
      {
        // 车系
        columnName: "series_name",
        columnType: 2,
        extra: {
          selectType: 0,
          optionList: this.state.seriesList,
        },
        // filter: 9,
        startVal: undefined,
        endVal: undefined,
        // filterTypeLock: true,
        // defaultField: true,
      },
      {
        columnName: "last7_mileage",
        columnType: 3,
        filter: undefined,
        startVal: undefined,
        endVal: undefined,
        filterType: "1",
      },
      {
        columnName: "risk_event_content",
        columnType: 2,
        extra: {
          selectType: 0,
          optionList: this.state.riskEventList.map((i) => ({
            value: i.uuid,
            label: i.riskEventContent,
          })),
        },
        // filter: 9,
        startVal: undefined,
        endVal: undefined,
      },
      {
        columnName: "warn_type",
        columnType: 2,
        extra: {
          selectType: 0,
          optionList: [
            {
              value: 0,
              label: "暂不支持",
            },
            {
              value: 1,
              label: "不可配置",
            },
            {
              value: 2,
              label: "可配置",
            },
          ],
        },
        // filter: 9,
        startVal: undefined,
        endVal: undefined,
      },
      {
        columnName: "warn_status",
        columnType: 2,
        extra: {
          selectType: 0,
          optionList: [
            {
              value: 0,
              label: "正常",
            },
            {
              value: 1,
              label: "车机告警",
            },
          ],
        },
        // filter: 9,
        startVal: undefined,
        endVal: undefined,
      },
      {
        columnName: "limp_enable",
        columnType: 2,
        extra: {
          selectType: 0,
          optionList: [
            {
              value: "0",
              label: "不支持",
            },
            {
              value: "1",
              label: "支持",
            },
          ],
        },
        // filter: 9,
        startVal: undefined,
        endVal: undefined,
      },
      {
        columnName: "repayment_status",
        columnType: 2,
        extra: {
          selectType: 0,
          optionList: [
            {
              // 0-还款中；1-已逾期；2-已结清；3-融资已到期
              value: "0",
              label: "还款中",
            },
            {
              value: "1",
              label: "已逾期",
            },
            {
              value: "99",
              label: "未知",
            },
            {
              value: "2",
              label: "已结清",
              hideInOption: true,
            },
            {
              value: "3",
              label: "融资已到期",
            },
          ],
        },
        // filter: 9,
        startVal: undefined,
        endVal: undefined,
      },
      {
        columnName: "risk_warn_status",
        columnType: 2,
        extra: {
          selectType: 0,
          optionList: [
            {
              // 1：预警  0或null：未预警 ；
              value: "0",
              label: "未预警",
            },
            {
              value: "1",
              label: "预警",
            },
          ],
        },
        // filter: 9,
        startVal: undefined,
        endVal: undefined,
      },
      {
        columnName: "engine_state",
        columnType: 2,
        extra: {
          selectType: 0,
          optionList: [
            {
              //  2-点火；0-熄火
              value: "0",
              label: "熄火",
            },
            {
              value: "2",
              label: "点火",
            },
            {
              value: "",
              label: "行驶中",
            },
          ],
        },
        // filter: 9,
        startVal: undefined,
        endVal: undefined,
      },
      {
        columnName: "risk_status",
        columnType: 2,
        extra: {
          selectType: 0,
          optionList: [
            {
              //   0-正常行驶，1-锁车，2-跛行
              value: "0",
              label: "正常行驶",
            },
            {
              value: "1",
              label: "锁车",
            },
            {
              value: "2",
              label: "跛行",
            },
          ],
        },
        // filter: 9,
        startVal: undefined,
        endVal: undefined,
      },
      {
        columnName: "credit_type",
        columnType: 2,
        extra: {
          selectType: 0,
          optionList: this.state.creditTypeOptions,
        },
        // filter: 9,
        startVal: undefined,
        endVal: undefined,
      },
    ];
  };

  exChangeDefaultData = (formValuesOutside) => {
    // 从外面带的属性
    // const { formValues } = this.state;
    const formValues = formValuesOutside || this.state.formValues;
    const {
      vin,
      riskStatus,
      overdueFlag,
      overdueDay,
      overdueDayEnd,
      overdueDateStart,
      overdueDateEnd,
      orgId,
      creditType
    } = formValues;
    // orgId: "17"
    // overdueDateEnd: "2022-12-15"
    // overdueDateStart: "2022-11-16"
    // overdueDay: 321
    // overdueFlag: "小于"
    // riskStatus: "1"
    // vin: "321"
    return [
      {
        columnName: "vin",
        columnType: 1,
        filter: vin ? "1" : undefined,
        startVal: vin,
        endVal: undefined,
        filterType: "1",
      },
      {
        columnName: "company_name",
        columnType: 2,
        filter: orgId ? "9" : undefined,
        startVal: orgId ? orgId : undefined,
        endVal: undefined,
        filterType: "1",
      },
      {
        columnName: "risk_status",
        columnType: 2,
        filter: riskStatus ? "9" : undefined,
        startVal: riskStatus,
        endVal: undefined,
        filterType: "1",
      },
      {
        columnName: "overdue_date",
        columnType: 4,
        filter: "7",
        startVal: overdueDateStart,
        endVal: overdueDateEnd,
        filterType: "1",
      },
      {
        columnName: "overdue_days",
        columnType: 3,
        filter:
          overdueFlag == "小于"
            ? "8"
            : overdueFlag == "大于"
            ? "6"
            : overdueFlag == "介于"
            ? "7"
            : undefined,
        startVal: overdueFlag ? overdueDay : undefined,
        endVal: overdueFlag ? overdueDayEnd : undefined,
        filterType: "1",
      },
      {
        columnName: "credit_type",
        columnType: 2,
        filter: creditType ? "9" : undefined,
        startVal: creditType? creditType : undefined,
        endVal: undefined,
        filterType: "1",
      },
    ];
  };

  handleOpenSeachModal = (e) => {
    // 更所筛选
    // console.log(e);
    // const exChangeData = this.exChangeDefaultData(); // 从外面带进来的值
    const specialData = this.specialDataGenrator(); // 特殊字段，本地定义
    const exChangeData = this.exChangeDefaultData(); // 从外面带进来的值
    this.SearchAdtionalRef.modalShow(specialData, exChangeData);
  };

  queryRecordList = () => {
    const { dispatch } = this.props;
    const { formValues, pageObj } = this.state;
    dispatch({
      type: "overdueCar/queryRecordList",
      payload: {
        // curPage: 1,
        // pageSize: 10,
        ...pageObj,
        ...formValues,
      },
    });
  };
  handleRangePicker = (fields) => {
    if (G.isNotEmptyAndNil(fields["overdueDate"])) {
      const [start, end] = fields.overdueDate;
      fields["overdueDateStart"] = moment(start).format("YYYY-MM-DD");
      fields["overdueDateEnd"] = moment(end).format("YYYY-MM-DD");
    } else {
      fields["overdueDateStart"] = null;
      fields["overdueDateEnd"] = null;
    }
    delete fields["overdueDate"];
  };
  //点击详情
  handleDetail = (record) => {
    sessionStorage.setItem("vin", JSON.stringify(record.vin));
    sessionStorage.setItem("overdueCarDetail", JSON.stringify(record));
    sessionStorage.setItem("typeOption", JSON.stringify(this.state.creditTypeOptions));
    sessionStorage.setItem(
      "backPath",
      "/creditPlatform/overdueCar"
    );
    this.props.dispatch(
      routerRedux.push({
        pathname:
          "/creditPlatform/overdueCarDetail",
      })
    );
  };
  handleDealWarning = (record) => {
    const { dispatch } = this.props;
    const orgId = record.orgId;
    dispatch({
      type: 'overdueCar/getDataWithRes',
      payload: {
        url: '/org/accountInfo/list',
        orgId,
      },
      callback: (response) => {
        this.setState({
          userList: response.data,
          sendMsgModalVisible: true,
          selectedRecord: record,
        });
      },
    });
  };
  handleLocation = (vin) => {
    sessionStorage.setItem("vin", vin);
    sessionStorage.setItem(
      "overdueCarLocationbackPath",
      "/creditPlatform/overdueCar"
    );
    sessionStorage.setItem("businessCode", "over-due-log");
    this.props.dispatch(
      routerRedux.push({
        pathname:
          "/creditPlatform/overdueCarLocation",
      })
    );
  };

  handleLockCar = (vin) => {
    this.props.dispatch({
      type: "overdueCar/postDataWithRes",
      payload: {
        url: "/mscreditbusiness/vehicle/lock/set",
        vin: vin,
        businessCode: "over-due-log",
      },
      callback: (response) => {
        if (response && response.statusCode == "0") {
          message.success("设置锁车成功");
          this.handleTableNewData();
        } else {
          message.error(response.statusMessage);
        }
      },
    });
  };

  handleUnlockCar = (vin) => {
    this.props.dispatch({
      type: "overdueCar/postDataWithRes",
      payload: {
        url: "/mscreditbusiness/vehicle/lock/remove",
        vin: vin,
        businessCode: "over-due-log",
      },
      callback: (response) => {
        if (response && response.statusCode == "0") {
          message.success("解除锁车成功");
          this.handleTableNewData();
        } else {
          message.error(response.statusMessage);
        }
      },
    });
  };
  /**
   * 解除跛行并锁车
   * @param {} vin
   */
  handleUnlimpAndLockCar = (vin) => {
    this.props.dispatch({
      type: "overdueCar/postDataWithRes",
      payload: {
        url: "/mscreditbusiness/vehicle/limp/remove",
        vin: vin,
        businessCode: "over-due-log",
      },
      callback: (response) => {
        if (response && response.statusCode == "0") {
          // message.success("解除跛行成功");
          this.props.dispatch({
            type: "overdueCar/postDataWithRes",
            payload: {
              url: "/mscreditbusiness/vehicle/lock/set",
              vin: vin,
              businessCode: "over-due-log",
            },
            callback: (response) => {
              if (response && response.statusCode == "0") {
                message.success("解除跛行并锁车成功");
                this.handleTableNewData();
              } else {
                message.error(response.statusMessage);
              }
            },
          });
        } else {
          message.error(response.statusMessage);
        }
      },
    });
  };

  handleLimp = (vin) => {
    this.props.dispatch({
      type: "overdueCar/postDataWithRes",
      payload: {
        url: "/mscreditbusiness/vehicle/limp/set",
        vin: vin,
        businessCode: "over-due-log",
      },
      callback: (response) => {
        if (response && response.statusCode == "0") {
          message.success("设置跛行成功");
          this.handleTableNewData();
        } else {
          message.error(response.statusMessage);
        }
      },
    });
  };
  /**
   * 解除锁车并跛行
   * @param {} vin
   */
  handleUnlockAndLimp = (vin) => {
    this.props.dispatch({
      type: "overdueCar/postDataWithRes",
      payload: {
        url: "/mscreditbusiness/vehicle/lock/remove",
        vin: vin,
        businessCode: "over-due-log",
      },
      callback: (response) => {
        if (response && response.statusCode == "0") {
          // message.success("解除跛行成功");
          this.props.dispatch({
            type: "overdueCar/postDataWithRes",
            payload: {
              url: "/mscreditbusiness/vehicle/limp/set",
              vin: vin,
              businessCode: "over-due-log",
            },
            callback: (response) => {
              if (response && response.statusCode == "0") {
                message.success("解除锁车并跛行成功");
                this.handleTableNewData();
              } else {
                message.error(response.statusMessage);
              }
            },
          });
        } else {
          message.error(response.statusMessage);
        }
      },
    });
  };

  handleUnlimp = (vin) => {
    this.props.dispatch({
      type: "overdueCar/postDataWithRes",
      payload: {
        url: "/mscreditbusiness/vehicle/limp/remove",
        vin: vin,
        businessCode: "over-due-log",
      },
      callback: (response) => {
        if (response && response.statusCode == "0") {
          message.success("解除跛行成功");
          this.handleTableNewData();
        } else {
          message.error(response.statusMessage);
        }
      },
    });
  };
  /**
   * tbox唤醒
   * @param {vin} vin
   */
  handleWakeUp = (vin) => {
    this.props.dispatch({
      type: "overdueCar/postDataWithRes",
      payload: {
        url: "/mscreditbusiness/vehicle/tbox/wake",
        vin,
        businessCode: "over-due-log",
      },
      callback: (response) => {
        if (response && response.statusCode == "0") {
          message.success("已经给该车辆发送远程唤醒指令");
          this.setState({
            tboxRouseloading: true,
          });
          let tboxRouseCount = 35;
          let tboxRouseSearchCount = 3;
          this.timer = setInterval(() => {
            tboxRouseCount--;
            this.setState({ tboxRouseCount });
            //请求详情接口
            if (tboxRouseCount <= 0) {
              this.setState({
                tboxRouseloading: false,
                tboxRouseCount: 35,
              });
              clearInterval(this.timer);
              message.error("TBOX没有被成功唤醒");
            }
          }, 1000);

          this.timer2 = setInterval(() => {
            tboxRouseSearchCount--;
            //请求详情接口
            this.props.dispatch({
              type: "overdueCar/postDataWithRes",
              payload: {
                url: "/mscreditbusiness/vehicle/tbox/wake/result",
                vin: vin,
              },
              callback: (response) => {
                if (response && response.statusCode == "0") {
                  console.log("请求接口详情", tboxRouseSearchCount);
                  //比较TBOX失联天数
                  // if (!response.data.tboxLostDays) {
                  if (response.data) {
                    message.success("TBOX被成功唤醒");
                    this.handleTableNewData();
                    clearInterval(this.timer2);
                    clearInterval(this.timer);
                    this.setState({
                      tboxRouseloading: false,
                      tboxRouseCount: 35,
                    });
                  }
                } else {
                  message.error(response.statusMessage);
                }
              },
            });

            if (tboxRouseSearchCount <= 0 || tboxRouseCount <= 0) {
              clearInterval(this.timer2);
            }
          }, 10000);
        } else {
          message.error(response.statusMessage);
        }
      },
      // callback: (response) => {
      //   if (response && response.statusCode == "0") {
      //     message.success(response.statusMessage)
      //     this.queryRecordList()
      //   } else {
      //     message.error(response.statusMessage)
      //   }
      // },
    });
  };

  /**
   * 行车轨迹
   * @param {*} record
   */
  handleTrack = (record) => {
    sessionStorage.setItem("overdue_track_vin", record.vin);
    const { formValues, pageObj } = this.state;
    this.props.dispatch(
      routerRedux.push({
        pathname: "/creditPlatform/overdueCarTrack",
        state: { pageObj, formValues },
      })
    );
  };
  handleTableChange = (page) => {
    this.setState(
      {
        pageObj: {
          curPage: page.current,
          pageSize: page.pageSize,
        },
      },
      () => {
        this.handleTableNewData();
      }
    );
    // const { dispatch } = this.props;
    // const { formValues } = this.state;
    // const params = {
    //   curPage: page.current,
    //   pageSize: page.pageSize,
    //   ...formValues,
    // };
    // this.setState({
    //   pageObj: {
    //     curPage: page.current,
    //     pageSize: page.pageSize,
    //   },
    // });
    // dispatch({
    //   type: "thirdOrgCreditVehicleOverdueCar/queryRecordListNew",
    //   payload: params,
    // });
  };
  showBtn = (record, type) => {
    // {
    //   label: "正常行驶",
    //   value: "0",
    // },
    // {
    //   label: "锁车",
    //   value: "1",
    // },
    // {
    //   label: "跛行",
    //   value: "2",
    // },
    const { limpEnable, riskStatus, tboxLostDays } = record;
    switch (type) {
      case "location": {
        return !(riskStatus == 1);
      }
      case "lockCar": {
        return riskStatus == 0;
      }
      case "unlimpAndLockCar": {
        return limpEnable == 1 && riskStatus == 2;
      }
      case "unlockCar": {
        return riskStatus == 1;
      }
      case "limp": {
        return limpEnable == 1 && riskStatus == 0;
      }
      case "unlockAndLimp": {
        return limpEnable == 1 && riskStatus == 1;
      }
      case "unlimp": {
        return limpEnable == 1 && riskStatus == 2;
      }
      case "wakeUp": {
        return tboxLostDays > 0;
      }
      default:
        return false;
    }
  };
  exportMonitorVehicle = async () => {//导出列表
    // handleTableNewDatatest
    const { dispatch } = this.props;
    // const { formValues } = this.state;
    let params = [];
    const {
      pageObj: { curPage, pageSize },
      fieldColumns,
      formValues,
      currentSearchMode,
    } = this.state;
    if (currentSearchMode == "1") {
      const value = await this.searchForm.getFieldsValue();
      params = this.exChangeDefaultData(value || []).filter(
        (i) =>
          !(
            i.startVal === undefined ||
            i.startVal === null ||
            i.startVal === ""
          )
      );
    } else {
      params = fieldColumns;
    }
    dispatch({
      type: "overdueCar/postObjWithRes",
      payload: {
        url: "/mscreditbusiness/vehicle/overdue/exportQueryTask",
        curPage,
        pageSize,
        conditions: params,
        // ...formValues,
      },
      callback: (response) => {
        if (response.statusCode === "0") {
          message.success("操作成功，请点击导出任务按钮查看导出进度！");
        } else if (response.statusCode === "12097023") {
          message.warning(
            "您有一个下载任务正在执行，请点击导出任务按钮查看导出进度！"
          );
        } else {
          message.error(response.statusMessage);
        }
      },
    });
  };
  openExportTaskModal = () => {
    this.setState({
      exportTaskVisible: true,
    });
  };
  changeExportTaskModalVisible = () => {
    this.setState({
      exportTaskVisible: false,
    });
  };
  changeriskStatusModalVisible = (flag) => {
    if (flag) {
      this.setState({
        riskStatusModalVisible: false,
      });
    } else {
      this.setState({
        riskStatusModalVisible: false,
      });
    }
  };
  //点击车辆风控状态
  handleriskStatus(text, record) {
    this.setState({
      riskvin: record.vin,
      riskStatusModalVisible: true,
    });
  }
  //点击地图查看逾期车辆
  viewMap = () => {
    sessionStorage.setItem(
      "backPathMap",
      "/creditPlatform/overdueCar"
    );
    sessionStorage.setItem("typeOption", JSON.stringify(this.state.creditTypeOptions));
    this.props.dispatch(
      routerRedux.push({
        pathname: "/creditPlatform/overdueCarMap",
      })
    );
  };
  //风控日志
  changeriskLogModalVisible = (flag) => {
    if (flag) {
      this.setState({
        riskLogModalVisible: false,
      });
    } else {
      this.setState({
        riskLogModalVisible: false,
      });
    }
  };
  handleRiskLog=(record)=>{
    this.setState({
      riskvin: record.vin,
      riskLogModalVisible: true,
    })
  }
  //点击经销商名称进入经销商风险管理页
  dealerRiskManage =(record)=>{
    const { dispatch } = this.props
    //获取当前经销商风险额度
    dispatch({
      type: 'overdueCar/postDataWithRes',
      payload: {
        url: '/mscreditbusiness/dealer/limit/get',  //  查询高风险经销商额度
        orgId: record.orgId,
        dealerCode: record.dealerCode
      },
      callback: (res) => {
        const { statusCode, data } = res;
        if (statusCode === '0') {
          this.setState({
            dealRiskManageModalVisible: true
          });
          this.dealRiskModal.setData({...data})
        }
      },
    })
    this.setState({
      dealRiskManageModalVisible: true
    })
  }
  render() {
    const {menu: { permissions }} = this.props;
    const {location: { pathname }} = this.props;
    const {dispatch} =this.props;
    const {
      sendMsgModalVisible,
      formValues,
      exportTaskVisible,
      selectedRecord,
      userList,
      tboxRouseloading,
      tboxRouseCount,
      fieldList,
      tableColumns,
      visible,
      checked,
      riskStatusModalVisible,
      orgList,
      tableData,
      total,
      tableLoading,
      pageObj: { curPage, pageSize },
      creditTypeOptions,
      riskLogModalVisible
    } = this.state;
    const pagination = {
      showSizeChanger: true,
      total: total,
      current: curPage,
      pageSize: pageSize,
      showTotal: () => {
        return <span>共&nbsp;{total}&nbsp;条</span>;
      },
    };
    const orgOptions = orgList.map((item) => {
      return {
        value: `${item.sid}`,
        label: item.name,
      };
    });
    const riskStatusOptions = [
      {
        label: "正常行驶",
        value: "0",
      },
      {
        label: "锁车",
        value: "1",
      },
      {
        label: "跛行",
        value: "2",
      },
    ];
    const searchItems = [
      {
        type: "input",
        title: "VIN号",
        key: "vin",
      },
      {
        type: "select",
        title: "车辆所属公司",
        key: "orgId",
        selectOptions: orgList,
        keyValue: ['sid', 'name'],
      },
      {
        type: "select",
        title: "车辆风控状态",
        key: "riskStatus",
        selectOptions: riskStatusOptions,
      },
      {
        type: "select",
        title: "授信类型",
        key: "creditType",
        selectOptions: creditTypeOptions,
      },
      {
        type: "rangePicker",
        title: "逾期起始日",
        key: "overdueDate",
        showTime: false,
        nohmsFormat: "YYYY-MM-DD",
        style: { width: "100%" },
      },
    ];
    const paginationProps = {
      showSizeChanger: true,
      showQuickJumper: true,
      ...pagination,
      showTotal: () => (
        <span>
          共&nbsp;{pagination === undefined ? 0 : pagination.total}&nbsp;条
        </span>
      ),
    };
    const detailBtnAuth = permissions.includes(pathname + '/' + 'overdueCar_detail');
    const dealWarningBtnAuth = permissions.includes(pathname + '/' + 'overdueCar_dealWarning');
    const locationBtnAuth = permissions.includes(pathname + '/' + 'overdueCar_location');
    const lockCarBtnAuth = permissions.includes(pathname + '/' + 'overdueCar_lockCar');
    const unlockCarBtnAuth = permissions.includes(pathname + '/' + 'overdueCar_unlockCar');
    const limpBtnAuth = permissions.includes(pathname + '/' + 'overdueCar_limp');
    const unlimpBtnAuth = permissions.includes(pathname + '/' + 'overdueCar_limp');
    const wakeUpBtnAuth = permissions.includes(pathname + '/' + 'overdueCar_wakeup');
    const trackBtnAuth = permissions.includes(pathname + '/' + 'overdueCar_track');

    const exportCarBtnAuth = permissions.includes(pathname + '/' + 'overdueCar_exportCar');
    const exportTaskBtnAuth = permissions.includes(pathname + '/' + 'overdueCar_exportTask');
    const mapViewBtnAuth = permissions.includes(pathname + '/' + 'overdueCar_mapView');

    const tboxBtn = {
      title: "操作",
      dataIndex: "opt",
      fixed: "right",
      align: "center",
      filterDropdown: <div></div>,
      filterIcon: (
        <Tooltip placement="top" title="筛选">
          <SettingOutlined 
            style={{ marginLeft: 1 }}
            onClick={() => this.openFieldModal()}
          />
        </Tooltip>
      ),
      // width: 200,
      render: (text, record) => {
        const btns = [];
        const { warnType, warnStatus } = record;
        const warnBtnAuth = permissions.includes(pathname + '/' + 'overdueCar-warn');
        const isWarn =
          warnBtnAuth &&
          warnType != 0 &&
          ((warnType == 1 && record.overdueDays >= 1) || warnType == 2);
        const detailBtn = {
          title: "详情",
          key: "detailBtn",
          onConfirm: () => this.handleDetail(record),
        };
        const dealWarningBtn = {
          title: "管理告警",
          key: "dealWarning",
          onConfirm: () => this.handleDealWarning(record),
        };
        const locationBtn = {
          title: "查看定位",
          key: "location",
          onConfirm: () => this.handleLocation(record?.vin),
        };
        const limp = {
          title: "跛行",
          Popconfirm: true,
          message:
            isWarn && warnType == 1
              ? "确认要设置跛行和车机告警吗?"
              : "确认跛行",
          key: "limp",
          onConfirm: () =>
            isWarn && warnType != 1
              ? this.handlemsgRulerList(record, 3)
              : this.handleLimp(record.vin),
        };
        const unlockAndLimp = {
          title: "跛行",
          Popconfirm: true,
          message:
            isWarn && warnType == 1
              ? "该车已处于锁车状态，是否解除锁车状态并实施跛行和车机告警吗？"
              : "该车已处于锁车状态，是否解除锁车状态并实施跛行？",
          key: "unlockAndLimp",
          // onConfirm: () => this.handleUnlockAndLimp(record?.vin),
          onConfirm: () =>
            isWarn && warnType != 1
              ? this.handlemsgRulerList(record, 3)
              : this.handleLimp(record.vin),
        };
        const lockCarBtn = {
          title: "锁车",
          Popconfirm: true,
          message:
            isWarn && warnType == 1
              ? "确认要设置锁车和车机告警吗?"
              : "确认锁车",
          key: "lockCarBtn",
          onConfirm: () =>
            isWarn && warnType != 1
              ? this.handlemsgRulerList(record, 2)
              : this.handleLockCar(record.vin),
        };

        const unlockCarBtn = {
          title: "解除锁车",
          Popconfirm: true,
          message: "确认解锁车辆",
          key: "unlockCarBtn",
          onConfirm: () => this.handleUnlockCar(record?.vin),
        };
        const unlimpAndLockCarBtn = {
          title: "锁车",
          Popconfirm: true,
          message:
            isWarn && warnType == 1
              ? "该车已处于跛行状态，是否解除跛行状态并实施锁车和车机告警吗？"
              : "该车已处于跛行状态，是否解除跛行状态并实施锁车？",
          key: "unlimpAndLockCar",
          onConfirm: () =>
            isWarn && warnType != 1
              ? this.handlemsgRulerList(record, 2)
              : this.handleUnlimpAndLockCar(record.vin),
        };
        const unlimp = {
          title: "解除跛行",
          Popconfirm: true,
          message: "确认解除跛行",
          key: "unlimp",
          onConfirm: () => this.handleUnlimp(record?.vin),
        };
        const track = {
          title: "行车轨迹",
          key: "trackBtn",
          onConfirm: () => this.handleTrack(record),
        };
        const wakeUp = {
          title: "TBOX唤醒",
          Popconfirm: true,
          message: "是否要对TBOX进行远程唤醒?",
          key: "wakeUp",
          onConfirm: () => this.handleWakeUp(record?.vin),
        };
        const riskLogBtn = {//若手动或自动实施锁车/解除锁车/跛行/解除跛行后，则显示风控日志按钮
          title: "风控日志",
          key: "riskLogBtn",
          onConfirm: () => this.handleRiskLog(record),
        };
        if(record.riskStatus == 1) btns.push(riskLogBtn);//风控日志
        if (detailBtnAuth) {
          btns.push(detailBtn);
        }
        if (locationBtnAuth && this.showBtn(record, "location")) {
          btns.push(locationBtn);
        }
        if (dealWarningBtnAuth) {
          btns.push(dealWarningBtn);
        }
        if (lockCarBtnAuth && this.showBtn(record, "lockCar")) {
          btns.push(lockCarBtn);
        }
        if (lockCarBtnAuth && this.showBtn(record, "unlimpAndLockCar")) {
          btns.push(unlimpAndLockCarBtn);
        }
        if (unlockCarBtnAuth && this.showBtn(record, "unlockCar")) {
          btns.push(unlockCarBtn);
        }
        if (limpBtnAuth && this.showBtn(record, "limp")) {
          btns.push(limp);
        }
        if (limpBtnAuth && this.showBtn(record, "unlockAndLimp")) {
          btns.push(unlockAndLimp);
        }
        if (unlimpBtnAuth && this.showBtn(record, "unlimp")) {
          btns.push(unlimp);
        }
        if (trackBtnAuth) {
          btns.push(track);
        }
        // btns.push(track)
        if (wakeUpBtnAuth && this.showBtn(record, "wakeUp")) {
          btns.push(wakeUp);
        }

        const msgRulerBtn = {
          title: "车机告警",
          Popconfirm: true,
          message: "是否车机告警",
          key: "msgrulerBtn",
          onConfirm: () =>
            warnType == 1
              ? this.handleWarnMsg(record)
              : this.handlemsgRulerList(record, 1),
        };
        const releaseRulertn = {
          title: "解除车机告警",
          Popconfirm: true,
          message: "是否解除车机告警",
          key: "msgremoverulerBtn",
          onConfirm: () => this.handlemsgRemove(record),
        };
        if (
          warnType != 0 &&
          ((warnType == 1 && record.overdueDays >= 1) || warnType == 2)
        ) {
          if (warnStatus == 0) {
            btns.push(msgRulerBtn);
          } else {
            btns.push(releaseRulertn);
          }
        }

        return (
          <PateoAuthButtons
            authStr="overdueCar"
            btns={btns}
          />
        );
      },
    };
    return (
      <Spin
        spinning={tboxRouseloading}
        size="large"
        tip={`Loading(${tboxRouseCount})s`}
      >
        <div>
          <Card bordered={false}>
            <div className={styles.tableList}>
              <CustomerSearchForm
                onRef={(searchForm) => (this.searchForm = searchForm)}
                searchItems={searchItems}
                orgList={orgList}
                // fetchUrl="thirdOrgCreditVehicleOverdueCar/queryRecordListNew"//分页查询逾期车辆列表
                customHandleFormReset={(e) => {
                  this.setState(
                    {
                      formValues: {},
                      fieldColumns: [],
                      pageObj: {
                        curPage: 1,
                        pageSize: 10,
                      },
                      creditType: undefined,
                      currentSearchMode: "1",
                    },
                    () => {
                      this.handleTableNewData();
                    }
                  );
                }}
                customHandleSearch={(e) => {
                  console.log(e);
                  this.setState(
                    {
                      pageObj: {
                        curPage: 1,
                        pageSize: 10,
                      },
                      currentSearchMode: "1",
                    },
                    () => {
                      this.handleTableNewData();
                    }
                  );
                }}
                payloadUrl={{ curPage: 1, pageSize: 10 }}
                dispatch={dispatch}
                handleRangePicker={this.handleRangePicker}
                saveFormValues={(val) =>
                  this.setState({ formValues: Object.assign(formValues, val) })
                }
                // handleFormReset={() => {
                //   console.log('?????');
                //   this.setState({ formValues: {} })
                //   this.SearchAdtionalRef.reset();
                //   this.handleTableNewData();
                // }}
                moreFn={(e) => this.handleOpenSeachModal(e)}
              />
              {exportCarBtnAuth ? (
                <Button
                  type="primary"
                  style={{ marginBottom: 10, marginRight: 10 }}
                  onClick={() => this.exportMonitorVehicle()}
                >
                  导出逾期车辆
                </Button>
              ) : null}
              {exportTaskBtnAuth ? (
                <Button
                  type="primary"
                  style={{ marginBottom: 10, marginRight: 10 }}
                  onClick={() => this.openExportTaskModal()}
                >
                  导出任务
                </Button>
              ) : null}
              {mapViewBtnAuth ? (
                <Button
                  type="primary"
                  style={{ marginBottom: 10, marginRight: 10 }}
                  onClick={() => this.viewMap()}
                >
                  地图查看逾期车辆
                </Button>
              ) : null}
              <Table
                rowKey={(record) => record.vin}
                columns={tableColumns
                  .filter((i) => i.columnShow)
                  .concat([tboxBtn])}
                dataSource={tableData}
                loading={tableLoading}
                formValues={this.state.formValues}
                pagination={paginationProps}
                onChange={(pagination) => {
                  this.setState(
                    {
                      pageObj: {
                        curPage: pagination.current,
                        pageSize: pagination.pageSize,
                      },
                    },
                    () => {
                      this.handleTableNewData();
                    }
                  );
                }}
                scroll={{ x: "max-content" }}
              />
            </div>
          </Card>
          {exportTaskVisible ? (
            <ExportTaskModal
              changeExportTaskModalVisible={this.changeExportTaskModalVisible}
            />
          ) : null}
          {sendMsgModalVisible && (
            <SendMsgModal
              changeVisible={() =>
                this.setState({ sendMsgModalVisible: false })
              }
              visible={sendMsgModalVisible}
              userList={userList}
              record={selectedRecord}
              dispatch={dispatch}
              // handleSearch={this.queryRecordList}
            />
          )}
          <FieldModal
            onRef={(fieldModal) => (this.fieldModal = fieldModal)}
            fieldName="overdue"
            dispatch={this.props.dispatch}
            onSubmit={(tableColumns) => {
              this.setState({
                tableColumns,
              });
            }}
            tableColumns={tableColumns}
          />
          <SearchAdtional
            onRef={(ref) => (this.SearchAdtionalRef = ref)} // ref赋值
            SearchAdtionalOptions={this.state.fieldMore} // 可选字段
            specialData={this.state.specialData} // 特殊字段
            fieldName="overdue"
            handleSubmit={(columns) => {
              // 点击确认搜索
              this.setState(
                {
                  fieldColumns: columns,
                  currentSearchMode: "2",
                },
                () => {
                  this.handleTableNewData();
                }
              );
            }}
          ></SearchAdtional>

          {this.state.msgRuleModalVisible && (
            <MsgRulerModal
              changeVisible={() => {
                this.setState({ msgRuleModalVisible: false });
                // this.handleTableNewData();
              }}
              onOk={() => {
                this.setState({ msgRuleModalVisible: false });
                this.handleTableNewData();
              }}
              businessCode="over-due-log"
              visible={this.state.msgRuleModalVisible}
              ruleList={this.state.ruleList}
              ruleListType={this.state.ruleListType}
              record={this.state.ruleListSelectedRecord}
              dispatch={this.props.dispatch}
            />
          )}
          {riskStatusModalVisible ? (
            <RiskStatusModal
              changeriskStatusModalVisible={this.changeriskStatusModalVisible}
              riskvin={this.state.riskvin}
            />
          ) : null}
           <DealerRiskManageModal
           changeVisible={() => {
            this.setState({ dealRiskManageModalVisible: false });
          }}
             modalVisible={this.state.dealRiskManageModalVisible}
             onRef={(dealRiskModal) => (this.dealRiskModal = dealRiskModal)}
            dispatch={this.props.dispatch}
          />
          {riskLogModalVisible ? (<RiskLogModal
            changeriskLogModalVisible={this.changeriskLogModalVisible}
            riskvin={this.state.riskvin}
          />) :null}
        </div>
      </Spin>
    );
  }
}
